<script>
  let obj1 = {
    a: 10,
    b: {
      c: 1,
      d: {
        e: 100,
      },
    },
  };
  let obj2 = {
    a: 10,
    b: {
      c: 1,
      d: {
        e: 10,
      },
    },
  };
  function isObj(obj) {
    return typeof obj === "object" && obj !== null;
  }
  // console.log(obj1==obj2);
  function isEqual(obj1, obj2) {
    if (!isObj(obj1) || !isObj(obj2)) {
      // console.log(obj1,obj2);
      return obj1 === obj2;
    }
    if (Object.keys(obj1).length !== Object.keys(obj2).length) {
      return false;
    }
    if (obj1 === obj2) {
      return true;
    }
    let flag = false;
    if (typeof obj1 == "object" && typeof obj2 == "object") {
      for (const key in obj1) {
        const flag = isEqual(obj1[key], obj2[key]);
        if (!flag) {
          return flag;
        }
      }
    }
  }
  console.log(isEqual(obj1, obj2));
</script>
